/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2005
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.model.disc.analysismodel;

import br.ufmg.dees.insane.model.disc.element.FrameElement;
import br.ufmg.dees.insane.util.IMatrix;
import br.ufmg.dees.insane.util.IVector;


/**
*A class representing an bar analysis model in one dimensional problems of a ParametricElement.
*
*@author Lucas, Marcelo & Pitangueira, Roque
*@version 1.0
*@since October 2004
*@see model.discrete.element.ParametricElement
*/

public class Line_1D extends LineAnalysisM implements java.io.Serializable 
{

//********************************************************************************

	private static final long serialVersionUID = 1L;

	/** Constructs a Line_1D line analysis model, sets its ndf, define validEquations and type.*/	
	public Line_1D()
	{
		this.setNdf(1);
		this.setValidEquation(0,true);
		this.setValidEquation(1,false);
		this.setValidEquation(2,false);
		this.setValidEquation(3,false);
		this.setValidEquation(4,false);
		this.setValidEquation(5,false);
		this.setType("Line_1D");
	}
	
//********************************************************************************

	/** Return the normal vector according this analysis model.
	*@param a The IMatrix of local derivates.
	*@param b The IMatrix of nodal coordinates.
	*@return The normal vector according this analysis model.
	*/
	protected IVector getNormalVector(IMatrix a, IMatrix b)
	{
		int nNos = (a.getNumCol());
		IVector normal = new IVector(1);
		IVector vectorX = new IVector(nNos);
		IVector n_Xi = new IVector(nNos);
		
		normal.zero();
		vectorX.zero();
		n_Xi.zero();
 
 //vectorX = b
		b.getColumn(0,vectorX);

		a.getRow(0,n_Xi);
		
		double dX_dXi = n_Xi.dot(vectorX);
		double dXi_dS = 1/(Math.sqrt((dX_dXi*dX_dXi)));
		
		normal.setElement(0,(dX_dXi*dXi_dS));
		
		return normal;
	}
	public IMatrix transformationMatrix(FrameElement elm) {
		return null;
	} 
	
//********************************************************************************

}
